import { useGetUserRoles } from "@/lib/store/useGetRoles";
import { useSubModuleStore } from "@/lib/store/useSubModuleStore";

import SubModuleForm from "./SubmoduleForm";
//import { Checkbox } from "@radix-ui/react-checkbox";

export default function UserSubRoles(data: any) {
    const { userRoles } = useGetUserRoles();
    const { subModules } = useSubModuleStore();

    return (
        <div className="flex flex-row flex-wrap">
            {subModules?.map((m: any) => {
                const hasRole: any = userRoles.filter(
                    (r: any) =>
                        r.user_id.includes(data.user.user_id) &&
                        r.module_id === m.module_id
                );
                return (
                    <div key={m.module_id}>
                        <SubModuleForm
                            i={m}
                            hasRole={hasRole}
                            user={data.user}
                        />
                    </div>
                );
            })}
        </div>
    );
}
