Add a dropdown to choose between video calls and radio calls

This commit is contained in:
Robin Townsend 2022-05-26 13:52:06 -04:00
commit cbfd03f9c6
10 changed files with 132 additions and 58 deletions

View file

@ -27,21 +27,21 @@ import { UserMenuContainer } from "../UserMenuContainer";
import { useModalTriggerState } from "../Modal";
import { JoinExistingCallModal } from "./JoinExistingCallModal";
import { useHistory } from "react-router-dom";
import { Headline, Title } from "../typography/Typography";
import { Title } from "../typography/Typography";
import { Form } from "../form/Form";
import { useShouldShowPtt } from "../useShouldShowPtt";
import { CallType, CallTypeDropdown } from "./CallTypeDropdown";
export function RegisteredView({ client }) {
const [callType, setCallType] = useState(CallType.Video);
const [loading, setLoading] = useState(false);
const [error, setError] = useState();
const history = useHistory();
const shouldShowPtt = useShouldShowPtt();
const onSubmit = useCallback(
(e) => {
e.preventDefault();
const data = new FormData(e.target);
const roomName = data.get("callName");
const ptt = data.get("ptt") !== null;
const ptt = callType === CallType.Radio;
async function submit() {
setError(undefined);
@ -68,7 +68,7 @@ export function RegisteredView({ client }) {
}
});
},
[client]
[client, callType]
);
const recentRooms = useGroupCallRooms(client);
@ -79,6 +79,9 @@ export function RegisteredView({ client }) {
history.push(`/${existingRoomId}`);
}, [history, existingRoomId]);
const callNameLabel =
callType === CallType.Video ? "Video call name" : "Radio call name";
return (
<>
<Header>
@ -92,16 +95,14 @@ export function RegisteredView({ client }) {
<div className={commonStyles.container}>
<main className={commonStyles.main}>
<HeaderLogo className={commonStyles.logo} />
<Headline className={commonStyles.headline}>
Enter a call name
</Headline>
<CallTypeDropdown callType={callType} setCallType={setCallType} />
<Form className={styles.form} onSubmit={onSubmit}>
<FieldRow className={styles.fieldRow}>
<InputField
id="callName"
name="callName"
label="Call name"
placeholder="Call name"
label={callNameLabel}
placeholder={callNameLabel}
type="text"
required
autoComplete="off"
@ -116,16 +117,6 @@ export function RegisteredView({ client }) {
{loading ? "Loading..." : "Go"}
</Button>
</FieldRow>
{shouldShowPtt && (
<FieldRow className={styles.fieldRow}>
<InputField
id="ptt"
name="ptt"
label="Push to Talk"
type="checkbox"
/>
</FieldRow>
)}
{error && (
<FieldRow className={styles.fieldRow}>
<ErrorMessage>{error.message}</ErrorMessage>