
import React, { FunctionComponent } from 'react';
import { IStyledProps } from '../../../../common/types';
import { TextStyle, ViewStyle } from 'react-native';
import { forwardCallToVoiceMail } from '../../../../../store/pbx/pbxSlice';
import { Logger } from '../../../../../utils/Log';
import { VoiceMailButtonView } from './VoiceMailButtonView';
import { IPbxCall } from '../../../../../store/pbx/types';
import { useAppDispatch } from '../../../../../store/hooks';

const logger = new Logger('VoiceCallButtonContainer');

interface IProps extends IStyledProps<{ icon?: TextStyle, container?: ViewStyle }> {
    call: IPbxCall
    iconCallName?: string
}

export const VoiceMailButton: FunctionComponent<IProps> = ({ call, iconCallName, style }) => {
    const dispatch =useAppDispatch();
    const onForwardIncomingCallToVoiceMail = () => {
        if (call) {
            logger.info('onForwardIncomingCallToVoiceMail');
            dispatch(forwardCallToVoiceMail(call.callId));
        }
    };

    return <VoiceMailButtonView onPress={onForwardIncomingCallToVoiceMail} callIconName={iconCallName} style={style} call={call} />;
};
