import React, { useState } from "react";
import { SettingButton } from "./settingButton";
import langIcon from './icons/languageIcon.svg';
import shareIcon from './icons/shareIcon.svg';
import pointerIcon from './icons/pointer2Icon.svg';
import exitIcon from './icons/exitIcon.svg';
import { LangButton } from "./langButton";

type TProps = {
    type: 'other' | 'selectLang'
    onClickShare?: () => void
    onClickChangeLang?: () => void
    onClickSelectLang?: () => void
    onClickExit?: () => void
}

export const SettingButtons:React.FC<TProps> = React.memo((props) => {
    const [currentLang, setCurrentLang] = useState<boolean>(true); //temp
    function changeLang() {
        setCurrentLang(!currentLang);
    }

    return <div className="setting-buttons-container">
        <div className="setting-buttons-row">
            {
                props.type === 'other' ?
                <>
                    <SettingButton
                        text="Пригласить"
                        icon={shareIcon}
                        helpIcon={pointerIcon}
                        onClick={props.onClickShare}
                    />
                    <SettingButton
                        text="Язык"
                        helpText="Русский"
                        icon={langIcon}
                        helpIcon={pointerIcon}
                        onClick={props.onClickChangeLang}
                    />
                </>
                :
                <>
                    <LangButton 
                        title="Русский"
                        caption="Русский"
                        isSelected={currentLang}
                        // onClick={props.onClickSelectLang}
                        onClick={changeLang}
                    />
                    <LangButton 
                        title="English"
                        caption="Английский"
                        isSelected={!currentLang}
                        // onClick={props.onClickSelectLang}
                        onClick={changeLang}
                    />
                </>
            }
        </div>
        {
            props.type === 'other' ?
            <SettingButton 
                text="Выйти"
                isExitButton={true}
                icon={exitIcon}
                onClick={props.onClickExit}
            />
            : null
        }
    </div>
})