
import React, { FunctionComponent } from 'react';
import { IImageButtonStyleProps, IStyledProps } from '../../../../common/types';
import { ImageSourcePropType } from 'react-native';
import { lockConference } from '../../../../../store/conference/conferenceSlice';
import { IConference } from '../../../../../store/conference/types';
import { LockConfButtonView } from './LockConfButtonView';
import { ImageButton } from '../../../../common/ImageButton';
import { useAppDispatch } from '../../../../../store/hooks';
interface IProps extends IStyledProps<IImageButtonStyleProps> {
    call: IConference
    imageSource?: ImageSourcePropType;
    renderOnPress?: (call: IConference) => void;
}
export const LockConfButton: FunctionComponent<IProps> = ({ call, imageSource, renderOnPress, style }) => {
const dispatch = useAppDispatch();
    const onLockConference = () => {
        if (renderOnPress) {
            renderOnPress(call);
        }
        else {
           dispatch(lockConference(call.callPeer.id));
        }
    };

    if (imageSource) {
        return <ImageButton style={style} imageSource={imageSource} onPress={onLockConference} />
    }
    else {
        return <LockConfButtonView call={call} onPress={onLockConference} style={style} />
    }
};
