From f45b86973d79ebcd6fd5955445a7dae20dbf8237 Mon Sep 17 00:00:00 2001 From: Jonas Schell Date: Tue, 2 May 2023 18:29:26 +0200 Subject: [PATCH] Add simple form validation to custom meet tab (#67) * Add simple form validation to custom meet tab * changes due to feedback --- pages/index.tsx | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 2ffa2a6..f988333 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,6 +1,6 @@ -import type { NextPage, GetServerSideProps, InferGetServerSidePropsType } from 'next'; +import type { GetServerSideProps, InferGetServerSidePropsType } from 'next'; import { useRouter } from 'next/router'; -import React, { ReactElement, useCallback, useEffect, useState } from 'react'; +import React, { ReactElement } from 'react'; import styles from '../styles/Home.module.css'; interface TabsProps { @@ -52,36 +52,45 @@ function DemoMeetingTab({ label }: { label: string }) { } function CustomConnectionTab({ label }: { label: string }) { - const [liveKitUrl, setLiveKitUrl] = useState(); - const [token, setToken] = useState(); - const router = useRouter(); - const join = () => { - router.push(`/custom/?liveKitUrl=${liveKitUrl}&token=${token}`); + const onSubmit: React.FormEventHandler = (event) => { + event.preventDefault(); + const formData = new FormData(event.target as HTMLFormElement); + const serverUrl = formData.get('serverUrl'); + const token = formData.get('token'); + router.push(`/custom/?liveKitUrl=${serverUrl}&token=${token}`); }; return ( -
+

Connect LiveKit Meet with a custom server using LiveKit Cloud or LiveKit Server.

- {/* */} - setLiveKitUrl(ev.target.value)}> - {/* */} - setToken(ev.target.value)}> + +