Skip to content

Commit

Permalink
access_code on joinCard autofill if viewerCode query param passed (#5610
Browse files Browse the repository at this point in the history
)

* viewerCode query param if passed autofills access_code on joinCard

* fixed eslint space error

* separate useEfect for viewerCode param
  • Loading branch information
SilentFlameCR authored Dec 13, 2023
1 parent 7422a46 commit 74d40f5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/javascript/components/rooms/room/join/JoinCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 74d40f5

Please sign in to comment.