From d1233cc1ad3227f2f1fb96ad846a89a6be33d089 Mon Sep 17 00:00:00 2001 From: PhilReact Date: Tue, 20 May 2025 14:34:38 +0300 Subject: [PATCH] fixed ts , added update and sell conditions --- package-lock.json | 9 +- package.json | 2 +- src/AppWrapper.tsx | 9 +- src/common/Spinners/BarSpinner/BarSpinner.tsx | 25 +- src/components/RegisterName.tsx | 32 ++- src/components/Tables/ForSaleTable.tsx | 70 ++--- src/components/Tables/NameTable.tsx | 239 +++++++++++------- src/components/Tables/PendingTxsTable.tsx | 14 +- src/hooks/useFetchNames.tsx | 20 ++ src/hooks/useHandleNameData.tsx | 23 +- src/hooks/useModal.tsx | 39 ++- src/interfaces/index.ts | 9 + src/pages/Market.tsx | 7 +- src/pages/MyNames.tsx | 24 +- src/state/contexts/FetchNamesProvider.tsx | 42 +++ src/state/contexts/PendingTxsProvider.tsx | 18 +- src/state/global/names.ts | 107 +++++++- 17 files changed, 481 insertions(+), 208 deletions(-) create mode 100644 src/hooks/useFetchNames.tsx create mode 100644 src/interfaces/index.ts create mode 100644 src/state/contexts/FetchNamesProvider.tsx diff --git a/package-lock.json b/package-lock.json index 11103c5..d724763 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@mui/icons-material": "^7.0.1", "@mui/material": "^7.0.1", "jotai": "^2.12.3", - "qapp-core": "^1.0.27", + "qapp-core": "^1.0.30", "react": "^19.0.0", "react-dom": "^19.0.0", "react-router-dom": "^7.3.0", @@ -3429,9 +3429,10 @@ } }, "node_modules/qapp-core": { - "version": "1.0.27", - "resolved": "https://registry.npmjs.org/qapp-core/-/qapp-core-1.0.27.tgz", - "integrity": "sha512-RNoHo1vx2K592X3w26+BAUSmDjfk4PIwDdUEyl+YIipYMRZDSCf1+TP3Rh93UGBMIxgcF58lQyXnKV1ttlHNQA==", + "version": "1.0.30", + "resolved": "https://registry.npmjs.org/qapp-core/-/qapp-core-1.0.30.tgz", + "integrity": "sha512-6UBeFrsFyOKMRNpQiWDENCuF9PXlbgkwiChh542i46cVFEUd7yuT+i8vlP3wWOrbQwsZtAAs4NI+zpiQuA7+KQ==", + "license": "MIT", "dependencies": { "@tanstack/react-virtual": "^3.13.2", "bloom-filters": "^3.0.4", diff --git a/package.json b/package.json index ac16f31..e487405 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@mui/icons-material": "^7.0.1", "@mui/material": "^7.0.1", "jotai": "^2.12.3", - "qapp-core": "^1.0.27", + "qapp-core": "^1.0.30", "react": "^19.0.0", "react-dom": "^19.0.0", "react-router-dom": "^7.3.0", diff --git a/src/AppWrapper.tsx b/src/AppWrapper.tsx index d9d1649..43d68a6 100644 --- a/src/AppWrapper.tsx +++ b/src/AppWrapper.tsx @@ -2,6 +2,7 @@ import { Routes } from './Routes'; import { GlobalProvider } from 'qapp-core'; import { publicSalt } from './qapp-config.ts'; import { PendingTxsProvider } from './state/contexts/PendingTxsProvider.tsx'; +import { FetchNamesProvider } from './state/contexts/FetchNamesProvider.tsx'; export const AppWrapper = () => { return ( @@ -18,9 +19,11 @@ export const AppWrapper = () => { appName: 'names', }} > - - - + + + + + ); }; diff --git a/src/common/Spinners/BarSpinner/BarSpinner.tsx b/src/common/Spinners/BarSpinner/BarSpinner.tsx index a51a512..25303e1 100644 --- a/src/common/Spinners/BarSpinner/BarSpinner.tsx +++ b/src/common/Spinners/BarSpinner/BarSpinner.tsx @@ -1,10 +1,17 @@ -import React from 'react' -import './barSpinner.css' -export const BarSpinner = ({width = '20px', color}) => { - return ( -
- ) +import './barSpinner.css'; + +interface BarSpinnerProps { + width: string | number; + color: string; } +export const BarSpinner = ({ width = '20px', color }: BarSpinnerProps) => { + return ( +
+ ); +}; diff --git a/src/components/RegisterName.tsx b/src/components/RegisterName.tsx index f3d9250..9a3865d 100644 --- a/src/components/RegisterName.tsx +++ b/src/components/RegisterName.tsx @@ -24,12 +24,7 @@ import CheckIcon from '@mui/icons-material/Check'; import ErrorIcon from '@mui/icons-material/Error'; import { useSetAtom } from 'jotai'; import { namesAtom, pendingTxsAtom } from '../state/global/names'; -export enum Availability { - NULL = 'null', - LOADING = 'loading', - AVAILABLE = 'available', - NOT_AVAILABLE = 'not-available', -} +import { Availability } from '../interfaces'; const Label = styled('label')` display: block; @@ -53,7 +48,7 @@ const RegisterName = () => { const [isLoadingRegisterName, setIsLoadingRegisterName] = useState(false); const theme = useTheme(); - const [nameFee, setNameFee] = useState(null); + const [nameFee, setNameFee] = useState(null); const registerNameFunc = async () => { if (!address) return; const loadId = showLoading('Registering name...please wait'); @@ -88,14 +83,18 @@ const RegisterName = () => { setNameValue(''); setIsOpen(false); } catch (error) { - showError(error?.message || 'Unable to register name'); + if (error instanceof Error) { + showError(error.message); + } else { + showError('Unable to register name'); + } } finally { setIsLoadingRegisterName(false); dismissToast(loadId); } }; - const checkIfNameExisits = async (name) => { + const checkIfNameExisits = async (name: string) => { if (!name?.trim()) { setIsNameAvailable(Availability.NULL); @@ -112,7 +111,6 @@ const RegisterName = () => { } } catch (error) { console.error(error); - } finally { } }; @@ -133,7 +131,7 @@ const RegisterName = () => { const data = await fetch(`/transactions/unitfee?txType=REGISTER_NAME`); const fee = await data.text(); - setNameFee((Number(fee) / 1e8).toFixed(8)); + setNameFee(Number((Number(fee) / 1e8).toFixed(8))); } catch (error) { console.error(error); } @@ -263,13 +261,13 @@ const RegisterName = () => { Close