From 74d40f520156959b8a00c9167b3505f36f06c88c Mon Sep 17 00:00:00 2001 From: Rahul Rodrigues Date: Wed, 13 Dec 2023 09:44:47 -0500 Subject: [PATCH] access_code on joinCard autofill if viewerCode query param passed (#5610) * viewerCode query param if passed autofills access_code on joinCard * fixed eslint space error * separate useEfect for viewerCode param --- app/javascript/components/rooms/room/join/JoinCard.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/javascript/components/rooms/room/join/JoinCard.jsx b/app/javascript/components/rooms/room/join/JoinCard.jsx index dc7a5a10d7..6c4034eade 100644 --- a/app/javascript/components/rooms/room/join/JoinCard.jsx +++ b/app/javascript/components/rooms/room/join/JoinCard.jsx @@ -65,6 +65,7 @@ export default function JoinCard() { const location = useLocation(); const queryParams = new URLSearchParams(location.search); const joinFormName = queryParams.get('joinFormName'); + const viewerCode = queryParams.get('viewerCode'); useEffect(() => { // set cookie to return to if needed const date = new Date(); @@ -98,6 +99,13 @@ export default function JoinCard() { } }, [joinFormName, currentUser?.name]); + useEffect(() => { + // Default viewerCode if passed as query param + if (viewerCode) { + methods.setValue('access_code', viewerCode); + } + }, [viewerCode]); + useEffect(() => { // Room channel subscription: if (roomStatusAPI.isSuccess) {