@@ -18,7 +18,7 @@ import {
1818} from "@chakra-ui/react" ;
1919import { GraphQLError } from "graphql" ;
2020import React , { useContext , useState } from "react" ;
21- import { Navigate , useNavigate } from "react-router-dom" ;
21+ import { Navigate , useNavigate , useSearchParams } from "react-router-dom" ;
2222
2323import LargerBackgroundImage from "../../assets/largerbackground.png" ;
2424import {
@@ -94,7 +94,9 @@ const SIGNUP = gql`
9494` ;
9595
9696const Join = ( ) : React . ReactElement => {
97- const [ role , setRole ] = useState < Role > ( "ASP" ) ;
97+ const [ searchParams ] = useSearchParams ( ) ;
98+ const defaultRole = ( searchParams . get ( "role" ) as Role ) || "ASP" ;
99+ const [ role , setRole ] = useState < Role > ( defaultRole ) ;
98100 const [ email , setEmail ] = useState ( "" ) ;
99101 const [ organizationName , setOrganizationName ] = useState ( "" ) ;
100102 const [ organizationDesc , setOrganizationDesc ] = useState ( "" ) ;
@@ -125,6 +127,7 @@ const Join = (): React.ReactElement => {
125127 if ( authenticatedUser ) {
126128 return < Navigate replace to = { ASP_DASHBOARD_PAGE } /> ;
127129 }
130+
128131
129132 const getTitleSection = ( ) : React . ReactElement => (
130133 < >
@@ -159,7 +162,13 @@ const Join = (): React.ReactElement => {
159162 Type of user
160163 </ FormLabel >
161164 < RadioGroup
162- onChange = { ( radioVal ) => setRole ( radioVal as Role ) }
165+ onChange = { ( radioVal ) => {
166+ setRole ( radioVal as Role ) ;
167+ // Update URL when role changes
168+ const newSearchParams = new URLSearchParams ( searchParams ) ;
169+ newSearchParams . set ( "role" , radioVal ) ;
170+ window . history . replaceState ( null , '' , `?${ newSearchParams . toString ( ) } ` ) ;
171+ } }
163172 value = { role }
164173 >
165174 < Stack direction = { { base : "column" , lg : "row" } } >
@@ -474,6 +483,7 @@ const Join = (): React.ReactElement => {
474483 navigate ( JOIN_SUCCESS_PAGE ) ;
475484 } catch ( e : unknown ) {
476485 if (
486+
477487 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
478488 // @ts -ignore
479489 e ?. graphQLErrors &&
0 commit comments