import {useThemeProvider} from "@contexts/themeContext";
import React from "react";
import GameTabs from "@components/GameTabs";
import styles from "./styles.module.scss";

const ModuleGameTabs=({data})=>{
    const {isMobile} = useThemeProvider();
    if (data==null)data={data:[]}
    const tabdata={};
    const parseTabs=()=>{
        let tabs=data.tabs!=null&&data.tabs.length>0?data.tabs:[];
        let items=data.data;
        if (items&&tabs.length===0){
            let temp={};
            for (let i = 0; i < items.length; i++) {
                let item=items[i];
                if (item){
                    let tabtype=item.tabtype;
                    if (temp[tabtype])continue;
                    tabs.push({tabtype:tabtype,title:item.title,icon:item.icon});
                    temp[tabtype]=true;
                }
            }
        }
        tabdata.tabs=tabs;
        tabdata.data=items;
        tabdata.tabtype=data.tabtype;
    }
    parseTabs();
    return (
        <>
            {
                tabdata.tabs.length>0? (
                    <div className={styles.container}>
                        <GameTabs data={tabdata}>

                        </GameTabs>
                    </div>
                ):(<></>)
            }
        </>
    )
}
export default ModuleGameTabs;
