import Box from "@/components/Box";
import HeaderBack from "@/components/HeaderBack";
import { getLocale, getTranslations } from "next-intl/server";

interface ItemProps {
    text: string;
}
interface GroupRep {
    heads: ItemProps[];
    group: ItemProps[];
    tails: ItemProps[];
    title: string;
}
interface TermsProps {
    policyData: GroupRep[];
}
const GamingPolicy = async () => {
    const t = await getTranslations("policy");
    const locale = await getLocale();
    const file = (await import(`/messages/${locale}.json`)).default;
    const target: TermsProps = file.policy;
    return (
        <>
            <HeaderBack />
            <main className={"main-header"}>
                <Box>
                    <header className={"mb-[0.05rem] text-[0.26rem] font-bold text-[#fcde26]"}>
                        {t("policyTitle")}
                    </header>
                    <h2 className={"mb-[0.05rem] font-bold"}>{t("policyTime")}</h2>

                    {target.policyData.map((terms, index) => {
                        return (
                            <div
                                key={index}
                                className={
                                    "mb-[0.18rem] border-b-[0.01rem] border-[#3f3f3f] pb-[0.18rem]"
                                }
                            >
                                <h2 className={"mb-[0.05rem] font-bold text-[#fcde26]"}>
                                    {terms.title}
                                </h2>
                                {terms.heads.map((item, index) => (
                                    <p key={index} className={"my-[0.05rem]"}>
                                        {item.text}
                                    </p>
                                ))}
                                <ul className={"pl-[0.18rem]"}>
                                    {terms.group?.map((item, graphIndex) => {
                                        return (
                                            <li
                                                key={graphIndex}
                                                className={
                                                    "my-[0.05rem] list-disc whitespace-pre-line"
                                                }
                                            >
                                                {item.text}
                                            </li>
                                        );
                                    })}
                                </ul>

                                {terms.tails.map((item, index) => (
                                    <p key={index} className={"my-[0.05rem]"}>
                                        {item.text}
                                    </p>
                                ))}
                            </div>
                        );
                    })}
                </Box>
            </main>
        </>
    );
};

export default GamingPolicy;
