mirror of
https://github.com/selfxyz/self.git
synced 2026-02-19 02:24:25 -05:00
* Refactor NFC scanner tests to use a global variable for platform OS, allowing dynamic switching between iOS and Android during tests. This change improves test isolation and avoids hoisting issues with jest.mock. * Triggering GitHub workflows * Add status animations and self logos * Update utilities and styles for statuses * Remove old LED implementation and occurences * Update Self QR Code with new design * Add status banner * Remove console and use QRcodeSteps in styles * Add ARIA and use Memo to prevent re-renders * Add refs for success and error callbacks * Use ref for self app in qrcode * Use selfapp ref consistently * Update connected state animtion * Skip 'parses Android response' test in nfcScanner --------- Co-authored-by: Justin Hernandez <justin.hernandez@self.xyz> Co-authored-by: Javier Cortejoso <javier.cortejoso@gmail.com>
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { statusConnecting, statusError, statusFailed, statusSuccess } from '../animations/index.js';
|
|
import selfLogoBlack from '../assets/self-logo-qr.svg';
|
|
|
|
export const QRcodeSteps = {
|
|
DISCONNECTED: 0,
|
|
WAITING_FOR_MOBILE: 1,
|
|
MOBILE_CONNECTED: 2,
|
|
PROOF_GENERATION_STARTED: 3,
|
|
PROOF_GENERATION_FAILED: 4,
|
|
PROOF_GENERATED: 5,
|
|
PROOF_VERIFIED: 6,
|
|
};
|
|
|
|
export const getStatusAnimation = (proofStep: number) => {
|
|
switch (proofStep) {
|
|
case QRcodeSteps.MOBILE_CONNECTED:
|
|
case QRcodeSteps.PROOF_GENERATION_STARTED:
|
|
case QRcodeSteps.PROOF_GENERATED:
|
|
return statusConnecting;
|
|
case QRcodeSteps.PROOF_VERIFIED:
|
|
return statusSuccess;
|
|
case QRcodeSteps.PROOF_GENERATION_FAILED:
|
|
return statusFailed;
|
|
default:
|
|
return statusError;
|
|
}
|
|
};
|
|
|
|
export const getStatusIcon = (proofStep: number): string => {
|
|
switch (proofStep) {
|
|
case QRcodeSteps.DISCONNECTED:
|
|
case QRcodeSteps.WAITING_FOR_MOBILE:
|
|
return selfLogoBlack;
|
|
default:
|
|
return '';
|
|
}
|
|
};
|
|
|
|
export const getStatusText = (proofStep: number): string => {
|
|
switch (proofStep) {
|
|
case QRcodeSteps.DISCONNECTED:
|
|
case QRcodeSteps.WAITING_FOR_MOBILE:
|
|
return 'Prove your Self';
|
|
case QRcodeSteps.MOBILE_CONNECTED:
|
|
case QRcodeSteps.PROOF_GENERATION_STARTED:
|
|
return 'Connected to Self';
|
|
case QRcodeSteps.PROOF_GENERATED:
|
|
return 'Proof Generated';
|
|
case QRcodeSteps.PROOF_VERIFIED:
|
|
return 'Proof Successful';
|
|
case QRcodeSteps.PROOF_GENERATION_FAILED:
|
|
return 'Proof Failed';
|
|
default:
|
|
return 'An error occurred';
|
|
}
|
|
};
|