import React from 'react';

import { sendDTMFSignal } from '../../store/currentCall/currentCallSlice';
import { callPBX } from '../../store/pbx/pbxSlice';
import { DialPadView } from './DialPadView';
import { IPbxCall } from '../../store/pbx/types';
import { useAppDispatch } from '../../store/hooks';
export interface IProps {
  showCallButton: boolean;
  currentCall?: IPbxCall;
}

export const DialPadContainer: React.FunctionComponent<IProps> = ({
  showCallButton,
  currentCall,
}) => {
  const dispatch = useAppDispatch();
  const onCallPbx = (callId:  string) =>{
    dispatch(callPBX(callId))
  }
  const onSendDTMFSignal = (digit:  string) =>{
    dispatch(sendDTMFSignal(digit))
  }
  return (
    <DialPadView
      callPBX={onCallPbx}
      showCallButton={showCallButton}
      sendDTMFSignal={onSendDTMFSignal}
      currentCall={currentCall}
    />
  );
};
