Skip to content

Commit

Permalink
TECH-292 - Remove ICP React Component
Browse files Browse the repository at this point in the history
  • Loading branch information
TYRONEMICHAEL committed Aug 13, 2024
1 parent c6c12e4 commit b809a56
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/civic_sign_frontend_demo/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,9 @@
import React, { useEffect, useState, useCallback, useMemo } from 'react';
import { Principal } from '@dfinity/principal';
import { CredentialService } from './service/CredentialService.js';
import { PrincipalService } from './service/PrincipalService.js';
import { config } from './config.js';
import { GatewayProvider, GatewayStatus, useGateway } from '@civic/icp-gateway-react';
import ICPCredentialCheckButton from '@civic/icp-gateway-react-ui';

function GatewayStatusLookup({ children, isLoggedIn }: { children: React.ReactNode; isLoggedIn: boolean }) {
const { gatewayStatus } = useGateway();
const [urlCode, setUrlCode] = useState<string | null>(null);

useEffect(() => {
console.log('Gateway status:', gatewayStatus);

// Parse the URL for the 'code' parameter
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');
setUrlCode(code);
}, [gatewayStatus]);

const retrievePass = () => {
const currentUrl = window.location.href;
const encodedRedirectUri = encodeURIComponent(currentUrl);
const passPortalUrl = `${config.portalUrl}/?redirect_uri=${encodedRedirectUri}`;
window.location.href = passPortalUrl;
};

const isActive = gatewayStatus === GatewayStatus.ACTIVE || urlCode === 'ACTIVE';

return (
<>
{children}
{isLoggedIn && (
<div>
<p>Gateway Status: {!isActive ? 'NOT_FOUND' : 'ACTIVE'}</p>
{isActive && (
<div>
<p>Active status detected!</p>
<img src={'https://www.icegif.com/wp-content/uploads/2023/01/icegif-162.gif'} alt="Cool GIF for active status" style={{ width: '100px', height: '100px' }} />
</div>
)}
</div>
)}
{gatewayStatus === GatewayStatus.NOT_REQUESTED && <button onClick={retrievePass}>Get Pass</button>}
</>
);
}

function App() {
const [principal, setPrincipal] = useState<Principal | undefined>(undefined);
const icpWallet = useMemo(() => ({ principal: principal?.toText() ?? undefined }), [principal]);
Expand Down

0 comments on commit b809a56

Please sign in to comment.