Use form elements and add submit handlers in chat, haircheck and the prejoin screen

This commit is contained in:
harshithpabbati 2022-02-08 14:43:21 +05:30
parent d735fb4e62
commit c683302ce3
3 changed files with 73 additions and 60 deletions

View File

@ -35,6 +35,10 @@ export const Intro = ({
}, [room]); }, [room]);
return ( return (
<form onSubmit={(e) => {
e.preventDefault();
onJoin(roomName, owner, fetchToken);
}}>
<Card> <Card>
<CardHeader>{title}</CardHeader> <CardHeader>{title}</CardHeader>
<CardBody> <CardBody>
@ -66,13 +70,14 @@ export const Intro = ({
</CardBody> </CardBody>
<CardFooter divider> <CardFooter divider>
<Button <Button
onClick={() => onJoin(roomName, owner, fetchToken)} type="submit"
disabled={!roomName || fetching} disabled={!roomName || fetching}
> >
{fetching ? 'Fetching token...' : 'Join meeting'} {fetching ? 'Fetching token...' : 'Join meeting'}
</Button> </Button>
</CardFooter> </CardFooter>
</Card> </Card>
</form>
); );
}; };

View File

@ -30,7 +30,7 @@ import { useDeepCompareMemo } from 'use-deep-compare';
* - Set user name and join call / request access * - Set user name and join call / request access
*/ */
export const HairCheck = () => { export const HairCheck = () => {
const { callObject, join } = useCallState(); const { callObject } = useCallState();
const { localParticipant } = useParticipants(); const { localParticipant } = useParticipants();
const { const {
deviceState, deviceState,
@ -167,13 +167,13 @@ export const HairCheck = () => {
/> />
<Button <Button
disabled={joining || userName.length < 3} disabled={joining || userName.length < 3}
onClick={() => joinCall(userName)} type="submit"
> >
Join call Join call
</Button> </Button>
</> </>
); );
}, [userName, joinCall, joining, setUserName]); }, [userName, joining, setUserName]);
return ( return (
<> <>
@ -222,7 +222,12 @@ export const HairCheck = () => {
</div> </div>
{tileMemo} {tileMemo}
</div> </div>
<form onSubmit={(e) => {
e.preventDefault();
joinCall(userName);
}}>
<footer>{waiting ? showWaitingMessage : showUsernameInput}</footer> <footer>{waiting ? showWaitingMessage : showUsernameInput}</footer>
</form>
</div> </div>
<style jsx>{` <style jsx>{`

View File

@ -57,6 +57,11 @@ export const ChatAside = () => {
</div> </div>
))} ))}
</div> </div>
<form onSubmit={(e) => {
e.preventDefault();
sendMessage(newMessage);
setNewMessage('');
}}>
<footer className="chat-footer"> <footer className="chat-footer">
<TextInput <TextInput
value={newMessage} value={newMessage}
@ -68,14 +73,12 @@ export const ChatAside = () => {
className="send-button" className="send-button"
variant="transparent" variant="transparent"
disabled={!newMessage} disabled={!newMessage}
onClick={() => { type="submit"
sendMessage(newMessage);
setNewMessage('');
}}
> >
Send Send
</Button> </Button>
</footer> </footer>
</form>
<style jsx>{` <style jsx>{`
.messages-container { .messages-container {
flex: 1; flex: 1;