Skip to content

Commit

Permalink
improve QR code handling and wallet select
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass committed Sep 6, 2024
1 parent c6472d1 commit a01374d
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 17 deletions.
4 changes: 2 additions & 2 deletions web/src/components/QRCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { App, Input, QRCode } from 'antd';
import { CopyOutlined, SendOutlined } from '@ant-design/icons';

const QRCodeComponent = ({ text, size }: { text: string; size?: number; }) => {
const QRCodeComponent = ({ text, size }: { text?: string; size?: number; }) => {

const { message } = App.useApp();

Expand Down Expand Up @@ -46,7 +46,7 @@ const QRCodeComponent = ({ text, size }: { text: string; size?: number; }) => {
)}
</div>
<div className='qr-code__link'>
<Input addonBefore={<CopyOutlined onClick={() => copyToClipbloard(text)} />} value={text} onChange={() => undefined} addonAfter={<SendOutlined onClick={() => gotoLink(text)} />} />
<Input addonBefore={<CopyOutlined onClick={() => copyToClipbloard(text ?? "")} />} value={text} onChange={() => undefined} addonAfter={<SendOutlined onClick={() => gotoLink(text ?? "")} />} />
</div>
</>
)
Expand Down
30 changes: 29 additions & 1 deletion web/src/context/globalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export enum Actions {
REQUEST_ISSUANCE,
CONNECT_DID,
SET_QR_CONTENT,
RESET_QR_CONTENT,
COMPLETE_ISSUANCE,
REQUEST_DOMAIN_LINKAGE_VALIDATION,
SET_DOMAIN_LINKAGE_VALIDATION,
Expand Down Expand Up @@ -86,6 +87,10 @@ interface SetQRContentAction extends ScopedReducerAction {
QRContent: string,
}

interface ResetQRContentAction extends ScopedReducerAction {
type: Actions.RESET_QR_CONTENT,
}

interface SetCompleteIssuanceAction extends ScopedReducerAction {
type: Actions.COMPLETE_ISSUANCE,
}
Expand Down Expand Up @@ -141,7 +146,21 @@ export type State = {
}
};

type ReducerAction = AddCredentialAction | ConnectDIDAction | RequestInviteAction | RequestInviteAction | RequestIssuanceAction | RequestPresentationAction | SetQRContentAction | SetCompleteIssuanceAction | SetIssuanceDataAction | RequestDomainLinkageValidationAction | SetDomainLinkageValidationAction | ResetStateAction | RequestParsedDIDAction | SetParsedDIDAction;
type ReducerAction = AddCredentialAction |
ConnectDIDAction |
RequestInviteAction |
RequestInviteAction |
RequestIssuanceAction |
RequestPresentationAction |
SetQRContentAction |
ResetQRContentAction |
SetCompleteIssuanceAction |
SetIssuanceDataAction |
RequestDomainLinkageValidationAction |
SetDomainLinkageValidationAction |
ResetStateAction |
RequestParsedDIDAction |
SetParsedDIDAction;

const socket = SocketIOClient("/", {
autoConnect: true,
Expand Down Expand Up @@ -370,6 +389,15 @@ export function GlobalStateProvider({ children }: any) {
};
}

case Actions.RESET_QR_CONTENT: {
return {
...state, [action.scope]: {
...state[action.scope],
QRcontent: undefined
}
};
}

case Actions.SET_ISSUANCE_DATA: {
return {
...state, [action.scope]: {
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Company/ProveIdentity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const ProveIdentity: React.FC = () => {
}, [nextStep, navigate]);

useEffect(() => {
dispatch?.({type: Actions.RESET_QR_CONTENT, scope: Scopes.CompanyHouse});
dispatch?.({type: Actions.REQUEST_INVITE, provider: Providers.Impierce, scope: Scopes.CompanyHouse});
}, [dispatch]);

Expand Down Expand Up @@ -54,8 +55,7 @@ const ProveIdentity: React.FC = () => {
<Trans i18nKey="pages.company.signIn.subtitle" />
</p>
<div className='qr-wrapper'>
{/* TODO: Handle loading state */}
<QRCode text={state[Scopes.CompanyHouse]?.QRcontent ?? ""} />
<QRCode text={state[Scopes.CompanyHouse]?.QRcontent} />
</div>
<p className='bold'>{t(status)}</p>
{loading && <Loading />}
Expand Down
5 changes: 3 additions & 2 deletions web/src/pages/Company/ProvideData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const ProvideData: React.FC = () => {
return navigate(fallbackRoute!.path.replace(":lng?", i18n.language.toString()));
}

dispatch?.({type: Actions.RESET_QR_CONTENT, scope: Scopes.CompanyHouse});

dispatch?.({
type: Actions.REQUEST_PRESENTATION,
provider: Providers.Impierce,
Expand Down Expand Up @@ -83,8 +85,7 @@ const ProvideData: React.FC = () => {
<Trans i18nKey="pages.company.provideData.subTitle" />
</p>
<div className='qr-wrapper'>
{/* TODO: Handle loading state */}
<QRCode text={state[Scopes.CompanyHouse]?.QRcontent ?? ""} />
<QRCode text={state[Scopes.CompanyHouse]?.QRcontent} />
</div>
<p className='bold'>{t(status)}</p>
{loading && <Loading />}
Expand Down
5 changes: 3 additions & 2 deletions web/src/pages/Company/ReceiveCredentials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const ReceiveCredentials: React.FC = () => {
return navigate(fallbackRoute!.path.replace(":lng?", i18n.language.toString()));
}

dispatch?.({type: Actions.RESET_QR_CONTENT, scope: Scopes.CompanyHouse});

dispatch?.({
type: Actions.REQUEST_ISSUANCE,
provider: Providers.Impierce,
Expand Down Expand Up @@ -75,8 +77,7 @@ const ReceiveCredentials: React.FC = () => {
<Trans i18nKey="pages.company.receiveCredentials.subTitle" />
</p>
<div className='qr-wrapper'>
{/* TODO: Handle loading state */}
<QRCode text={state[Issuers.CompanyHouse]?.QRcontent ?? ""} />
<QRCode text={state[Issuers.CompanyHouse]?.QRcontent} />
</div>
<p className='bold'>{t(status)}</p>
{loading && <Loading />}
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Government/ProveIdentity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const ProveIdentity: React.FC = () => {
}, [nextStep, navigate]);

useEffect(() => {
dispatch?.({type: Actions.RESET_QR_CONTENT, scope: Scopes.Government});
dispatch?.({type: Actions.REQUEST_INVITE, provider: Providers.TangleLabs, scope: Scopes.Government});
}, [dispatch]);

Expand Down Expand Up @@ -51,8 +52,7 @@ const ProveIdentity: React.FC = () => {
<Trans i18nKey="pages.government.signIn.subtitle" />
</p>
<div className='qr-wrapper'>
{/* TODO: Handle loading state */}
<QRCode text={state[Scopes.Government]?.QRcontent ?? ""} />
<QRCode text={state[Scopes.Government]?.QRcontent} />
</div>
<p className='bold'>{t(status)}</p>
{loading && <Loading />}
Expand Down
5 changes: 3 additions & 2 deletions web/src/pages/Government/ReceiveCredentials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const ReceiveCredentials: React.FC = () => {
return navigate(fallbackRoute!.path.replace(":lng?", i18n.language.toString()));
}

dispatch?.({type: Actions.RESET_QR_CONTENT, scope: Scopes.Government});

dispatch?.({
type: Actions.REQUEST_ISSUANCE,
provider: Providers.TangleLabs,
Expand Down Expand Up @@ -75,8 +77,7 @@ const ReceiveCredentials: React.FC = () => {
<Trans i18nKey="pages.government.receiveCredentials.subTitle" />
</p>
<div className='qr-wrapper'>
{/* TODO: Handle loading state */}
<QRCode text={state[Issuers.Government]?.QRcontent ?? ""} />
<QRCode text={state[Issuers.Government]?.QRcontent} />
</div>
<p className='bold'>{t(status)}</p>
{loading && <Loading />}
Expand Down
8 changes: 4 additions & 4 deletions web/src/styles/pages/appPicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
}

.circle {
position: absolute;
bottom: -250px;
position: fixed;
bottom: -400px;
z-index: 0;
width: 800px;

Expand Down Expand Up @@ -146,8 +146,8 @@
background-color: #ffffff;
padding: 15px 0 15px 15px;
border-radius: 5px;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.15);
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.09);
}

&__column {
Expand Down

0 comments on commit a01374d

Please sign in to comment.