Skip to content

Commit

Permalink
fix verification status display
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitayutanov committed Jan 24, 2025
1 parent 919fea3 commit b9d1e10
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion idea/gear/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react-gtm-module": "2.0.11",
"react-hook-form": "7.52.2",
"react-number-format": "5.3.1",
"react-router-dom": "6.16.0",
"react-router-dom": "6.28.2",
"react-transition-group": "4.4.5",
"sails-js": "0.3.0",
"sails-js-parser": "0.1.0",
Expand Down
5 changes: 3 additions & 2 deletions idea/gear/frontend/src/features/code-verifier/api/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HexString } from '@gear-js/api';
import { useAlert } from '@gear-js/react-hooks';
import { useMutation, useQuery } from '@tanstack/react-query';
import { STATUS_CODES } from 'http';
import { useEffect } from 'react';

import { getVerificationStatus, getVerifiedCode, verifyCode } from './requests';
Expand All @@ -18,14 +19,14 @@ function useIsCodeVerified(codeId: HexString | null | undefined) {
const query = useQuery({
queryKey: ['code-verification-status', codeId],
queryFn: () => getVerifiedCode(codeId!),
select: ({ idl_hash }) => Boolean(idl_hash),
select: (response) => Boolean(response),
enabled: Boolean(codeId),
});

const { error } = query;

useEffect(() => {
if (error) alert.error(error.message);
if (error && error.message !== STATUS_CODES[404]) alert.error(error.message);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [error]);

Expand Down
2 changes: 1 addition & 1 deletion idea/gear/frontend/src/pages/program/program.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const Program = () => {
<header className={styles.header}>
<div className={styles.headingContainer}>
{program && <h2 className={styles.name}>{getShortName(program.name || 'Program Name')}</h2>}
{!isCodeVerified && <VerificationStatus value="verified" />}
{isCodeVerified && <VerificationStatus value="verified" />}
</div>

<div className={styles.links}>
Expand Down
5 changes: 3 additions & 2 deletions idea/gear/frontend/src/shared/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GearApi, HexString } from '@gear-js/api';
import { Account, AlertContainerFactory } from '@gear-js/react-hooks';
import type { Event } from '@polkadot/types/interfaces';
import { isAndroid, isIOS } from '@react-aria/utils';
import { STATUS_CODES } from 'http';

import { ACCOUNT_ERRORS, NODE_ADRESS_URL_PARAM, FileTypes } from '@/shared/config';

Expand Down Expand Up @@ -105,7 +106,6 @@ const enableScroll = () => document.body.classList.remove('noOverflow');
const resetFileInput = (target: HTMLInputElement | null) => {
if (!target) return;


target.value = '';
const changeEvent = new Event('change', { bubbles: true });
target.dispatchEvent(changeEvent);
Expand Down Expand Up @@ -137,7 +137,8 @@ const fetchWithGuard = async <T extends object>(url: URL | string, method: 'GET'

if (!response.ok) {
const result = await response.json().catch(() => ({}));
throw new Error('error' in result ? result.error : response.statusText);

throw new Error('error' in result ? result.error : response.statusText || STATUS_CODES[response.status]);
}

return response.json() as T;
Expand Down
32 changes: 16 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4854,10 +4854,10 @@ __metadata:
languageName: node
linkType: hard

"@remix-run/router@npm:1.9.0":
version: 1.9.0
resolution: "@remix-run/router@npm:1.9.0"
checksum: 10c0/560ee341719634d273b8502e00e15b3dc4a0d245cb0a3d9663981a70967cba8675d0ac3ddd94e8f572ae66f6fd2618304130a077faec49bf30347c3241e64b28
"@remix-run/router@npm:1.21.1":
version: 1.21.1
resolution: "@remix-run/router@npm:1.21.1"
checksum: 10c0/a90e62c6f18e53d8a1f39de8aaebe3abd340ea085a761296f4fddda23bd3ad133f9adf0190392e0b02933761180b484e7fc052447a6a8482c52207fcecbf9a90
languageName: node
linkType: hard

Expand Down Expand Up @@ -13329,7 +13329,7 @@ __metadata:
react-gtm-module: "npm:2.0.11"
react-hook-form: "npm:7.52.2"
react-number-format: "npm:5.3.1"
react-router-dom: "npm:6.16.0"
react-router-dom: "npm:6.28.2"
react-transition-group: "npm:4.4.5"
sails-js: "npm:0.3.0"
sails-js-parser: "npm:0.1.0"
Expand Down Expand Up @@ -20105,27 +20105,27 @@ __metadata:
languageName: node
linkType: hard

"react-router-dom@npm:6.16.0":
version: 6.16.0
resolution: "react-router-dom@npm:6.16.0"
"react-router-dom@npm:6.28.2":
version: 6.28.2
resolution: "react-router-dom@npm:6.28.2"
dependencies:
"@remix-run/router": "npm:1.9.0"
react-router: "npm:6.16.0"
"@remix-run/router": "npm:1.21.1"
react-router: "npm:6.28.2"
peerDependencies:
react: ">=16.8"
react-dom: ">=16.8"
checksum: 10c0/f1d898115b395038bc44d295412f0ab480ee3057fb2306048bf64c9c4b3a6e4eba756b058a0557e71e86bddb1090d298849fa22c0d8aa5abcecfa3a61204f7a3
checksum: 10c0/09757f0f8c63d5b939176825536d2311edac1f32b18410eb2b37900774c8622dbaa340bef78ab46931111e30890c7bc3f83346d809c2664a5dc4866fe0175f41
languageName: node
linkType: hard

"react-router@npm:6.16.0":
version: 6.16.0
resolution: "react-router@npm:6.16.0"
"react-router@npm:6.28.2":
version: 6.28.2
resolution: "react-router@npm:6.28.2"
dependencies:
"@remix-run/router": "npm:1.9.0"
"@remix-run/router": "npm:1.21.1"
peerDependencies:
react: ">=16.8"
checksum: 10c0/914e3352f26d9d9e3f859483507d459f2bb01ca65fcd1a3f9c5dba91dd005b45e7aae32dbd0f777ea00ecf453dc0e20463d3bcbbdec6ce13f8235be377f66752
checksum: 10c0/07f033a0bfdcfee6cb889d8603b6063c04c7b7fe38567fea5c7e55c45f31cf32115c2615a7962685632df49538bc867368631feb84fd1fec6f709827d492abe8
languageName: node
linkType: hard

Expand Down

0 comments on commit b9d1e10

Please sign in to comment.