diff --git a/src/civic_sign_frontend_demo/src/App.tsx b/src/civic_sign_frontend_demo/src/App.tsx index e40d652..66346c5 100644 --- a/src/civic_sign_frontend_demo/src/App.tsx +++ b/src/civic_sign_frontend_demo/src/App.tsx @@ -1,14 +1,14 @@ import React, { useEffect, useState, useCallback, useMemo } from 'react'; import { Principal } from '@dfinity/principal'; import { PrincipalService } from './service/PrincipalService.js'; -import { config } from './config.js'; +import { config, GatekeeperNetwork } from './config.js'; import ICPCredentialCheckButton, { CredentialCheckResponse } from '@civic/icp-gateway-react-ui'; import { ChevronDown } from 'lucide-react'; function App() { const [principal, setPrincipal] = useState(undefined); const [urlCode, setUrlCode] = useState(null); - const [selectedGatekeeperNetwork, setSelectedGatekeeperNetwork] = useState(config.gatekeeperNetworks[0]); + const [selectedGatekeeperNetwork, setSelectedGatekeeperNetwork] = useState(config.gatekeeperNetworks[0]); // Assume we have an array of available gatekeeperNetworks const gatekeeperNetworks = useMemo(() => config.gatekeeperNetworks, []); @@ -42,7 +42,9 @@ function App() { }, []); const handleGatekeeperNetworkChange = useCallback((event: React.ChangeEvent) => { - setSelectedGatekeeperNetwork(event.target.value); + const selectedNetwork = gatekeeperNetworks.find((network) => network.name === event.target.value); + console.log('Selected network:', selectedNetwork); + setSelectedGatekeeperNetwork(selectedNetwork || gatekeeperNetworks[0]); }, []); return ( @@ -56,7 +58,7 @@ function App() {

Logged in as {principal?.toText()}

@@ -67,13 +69,13 @@ function App() {
diff --git a/src/civic_sign_frontend_demo/src/config.ts b/src/civic_sign_frontend_demo/src/config.ts index 6ea8e06..c479807 100644 --- a/src/civic_sign_frontend_demo/src/config.ts +++ b/src/civic_sign_frontend_demo/src/config.ts @@ -18,10 +18,11 @@ const civicBackendCanisterUrl = !isDev const portalUrl = `https://icp-getpass.civic.com`; +export type GatekeeperNetwork = { name: string, address: string }; const gatekeeperNetworks = [ - 'ta136ftcpd8RyTYu3FGBjstD7EMXGBWrcwotdScrAKu', - 'tunQheuPpHhjjsbrUDp4rikqYez9UXv4SXLRHf9Kzsv', - 'tigoYhp9SpCDoCQmXGj2im5xa3mnjR1zuXrpCJ5ZRmi' + { name: 'Age 13', address: 'ta136ftcpd8RyTYu3FGBjstD7EMXGBWrcwotdScrAKu', }, + { name: 'Uniqueness', address: 'tunQheuPpHhjjsbrUDp4rikqYez9UXv4SXLRHf9Kzsv', }, + { name: 'Captcha', address: 'tigoYhp9SpCDoCQmXGj2im5xa3mnjR1zuXrpCJ5ZRmi', }, ]; // This is for demo purposes but should be replaced with a more secure method