@@ -7,36 +7,36 @@ import App from '@/App.tsx'
77import { GoogleOAuthProvider } from '@react-oauth/google' ;
88
99function Root ( ) {
10- // const [googleClientId, setGoogleClientId] = useState<string | null>(null);
11- // const googleAuthBackendUrl = import.meta.env.VITE_GOOGLE_AUTH_URL;
10+ const [ googleClientId , setGoogleClientId ] = useState < string | null > ( null ) ;
11+ const googleAuthBackendUrl = import . meta. env . VITE_GOOGLE_AUTH_URL ;
1212
13- // useEffect(() => {
14- // const fetchClientId = async () => {
15- // try {
16- // const response = await fetch(`${googleAuthBackendUrl}/google-auth/client-id`);
17- // if (!response.ok) {
18- // throw new Error(`Failed to fetch client ID: ${response.statusText}`);
19- // }
20- // const data = await response.json();
21- // setGoogleClientId(data.client_id);
22- // } catch (error) {
23- // console.error("Error fetching Google Client ID:", error);
24- // // Handle error appropriately, e.g., show an error message to the user
25- // }
26- // };
27- // fetchClientId();
28- // }, []);
13+ useEffect ( ( ) => {
14+ const fetchClientId = async ( ) => {
15+ try {
16+ const response = await fetch ( `${ googleAuthBackendUrl } /google-auth/client-id` ) ;
17+ if ( ! response . ok ) {
18+ throw new Error ( `Failed to fetch client ID: ${ response . statusText } ` ) ;
19+ }
20+ const data = await response . json ( ) ;
21+ setGoogleClientId ( data . client_id ) ;
22+ } catch ( error ) {
23+ console . error ( "Error fetching Google Client ID:" , error ) ;
24+ // Handle error appropriately, e.g., show an error message to the user
25+ }
26+ } ;
27+ fetchClientId ( ) ;
28+ } , [ ] ) ;
2929
30- // if (!googleClientId) {
31- // // Optionally render a loading spinner or message
32- // return <div>Loading Google authentication...</div>;
33- // }
30+ if ( ! googleClientId ) {
31+ // Optionally render a loading spinner or message
32+ return < div > Loading Google authentication...</ div > ;
33+ }
3434
3535 return (
3636 < StrictMode >
37- { /* <GoogleOAuthProvider clientId={googleClientId}> */ }
38- < App />
39- { /* </GoogleOAuthProvider> */ }
37+ < GoogleOAuthProvider clientId = { googleClientId } >
38+ < App />
39+ </ GoogleOAuthProvider >
4040 </ StrictMode >
4141 ) ;
4242}
0 commit comments