import React, {ReactNode} from "react";
import './customselect.scss'
import {CustomSelectOptions} from "../../../../models/ReactComponents";
import {extractPlainTextFromChild} from "../../../../helpers/functions";
import CustomSelect, {CustomSelectProps} from "./CustomSelect";
import SelectItem from "./SelectItem";

interface MakeCustomSelectProps extends Omit<CustomSelectProps, 'children'> {
    options: CustomSelectOptions
    children?: ReactNode
    showEng?: boolean
}

// @ts-ignore
/***
 *
 *GENERRATES CUSTOM SELECT COMPONETNS FROM OPTIONS OBJECT
 */

export default function MakeCustomSelect({children,
                                             options,
                                             showEng,
                                             ...props
                                         }: MakeCustomSelectProps) {
    return (

        // @ts-ignore
        <CustomSelect
            {...props}
        >
            {
                options?.map(opt => {
                    return <SelectItem key={opt.value} value={opt.value}>{ opt.name}</SelectItem>
                })
            }
        </CustomSelect>

    );
}
