diff --git a/phone/src/modal/components/CallModal.tsx b/phone/src/modal/components/CallModal.tsx index 7c7fe87..3dd9169 100644 --- a/phone/src/modal/components/CallModal.tsx +++ b/phone/src/modal/components/CallModal.tsx @@ -1,29 +1,68 @@ -import React from 'react'; -import { green } from '@material-ui/core/colors'; +import React, { useState } from 'react'; +import { Button, Fab } from '@material-ui/core'; import { AppWrapper } from '../../ui/components/AppWrapper'; import { AppTitle } from '../../ui/components/AppTitle'; import { AppContent } from '../../ui/components/AppContent'; +import { useCall } from '../hooks/useCall'; +import CallIcon from '@material-ui/icons/Call'; +import PhoneDisabledIcon from '@material-ui/icons/PhoneDisabled'; +import CallEndIcon from '@material-ui/icons/CallEnd'; +import useStyles from './modal.styles'; +import { useModal } from '../hooks/useModal'; export const CallModal = () => { + const { call, setCall } = useCall(); + const { setModal } = useModal() + const [accepted, setAccepted] = useState(false) + + const classes = useStyles() + + const handleAcceptCall = () => { + setAccepted(true) + } + + const handleRejectCall = () => { + setModal(false) + setCall(null) + } + + const handleEndCall = () => { + setModal(false) + setCall(null) + } + return ( - -

- Call -

+

{call.target}

+ +
+ {!accepted ? ( + <> + + + + + + + + ) : ( + + + + )} +
); diff --git a/phone/src/modal/components/modal.styles.ts b/phone/src/modal/components/modal.styles.ts new file mode 100644 index 0000000..17c88c4 --- /dev/null +++ b/phone/src/modal/components/modal.styles.ts @@ -0,0 +1,18 @@ +import { makeStyles, Theme } from '@material-ui/core/styles'; + +const useStyles = makeStyles((theme: Theme) => ({ + actions: { + width: '100%', + margin: 'auto', + display: 'flex', + alignContent: 'center', + justifyContent: 'center', + marginTop: '5em' + }, + actionButton: { + margin: 20 + } +})) + + +export default useStyles; \ No newline at end of file diff --git a/phone/src/modal/hooks/state.ts b/phone/src/modal/hooks/state.ts index 5205d4a..03a4814 100644 --- a/phone/src/modal/hooks/state.ts +++ b/phone/src/modal/hooks/state.ts @@ -1,8 +1,12 @@ import { atom } from 'recoil'; export const callerState = { - caller: atom({ - key: 'callerList', - default: [], + currentCall: atom({ + key: 'currentCall', + default: null }), + callModal: atom({ + key: 'callingModal', + default: false + }) }; diff --git a/phone/src/modal/hooks/useCall.ts b/phone/src/modal/hooks/useCall.ts index ecf52d0..6adc8ea 100644 --- a/phone/src/modal/hooks/useCall.ts +++ b/phone/src/modal/hooks/useCall.ts @@ -1,7 +1,13 @@ import { useRecoilState } from 'recoil'; +import { CallProps } from '../../common/typings/call'; import { callerState } from './state'; -export const useCall = () => { - const caller = useRecoilState(callerState.caller); - return { caller }; +interface CallHook { + call: CallProps; + setCall: (details: any) => void; +} + +export const useCall = (): CallHook => { + const [call, setCall] = useRecoilState(callerState.currentCall); + return { call, setCall }; }; diff --git a/phone/src/modal/hooks/useCallService.ts b/phone/src/modal/hooks/useCallService.ts index 17fcabc..e81816c 100644 --- a/phone/src/modal/hooks/useCallService.ts +++ b/phone/src/modal/hooks/useCallService.ts @@ -2,9 +2,13 @@ import { useNuiEvent } from '../../os/nui-events/hooks/useNuiEvent'; import { useSetRecoilState } from 'recoil'; import { callerState } from './state'; import { useCall } from './useCall'; +import { useModal } from './useModal'; export const useCallService = () => { - const setCaller = useSetRecoilState(callerState.caller); + const setCaller = useSetRecoilState(callerState.currentCall); + const setModal= useSetRecoilState(callerState.callModal); + useNuiEvent('CALL', 'setCaller', setCaller); - return useCall(); + useNuiEvent('CALL', 'callModal', setModal); + return { useCall, useModal }; }; diff --git a/phone/src/modal/hooks/useModal.ts b/phone/src/modal/hooks/useModal.ts new file mode 100644 index 0000000..3ac7069 --- /dev/null +++ b/phone/src/modal/hooks/useModal.ts @@ -0,0 +1,12 @@ +import { useRecoilState } from 'recoil'; +import { callerState } from './state'; + +interface ModalProps { + modal: boolean; + setModal: (show: boolean) => void; +} + +export const useModal = (): ModalProps => { + const [modal, setModal] = useRecoilState(callerState.callModal); + return { modal, setModal } +} \ No newline at end of file