From 7a56f3c8033e4193977a6974ed872ff0cf365861 Mon Sep 17 00:00:00 2001 From: PhilReact Date: Sun, 29 Dec 2024 12:25:51 +0200 Subject: [PATCH] batch of updates 5 --- src/App.tsx | 167 +++++++++++++----- src/background.ts | 6 +- src/common/BoundedNumericTextField.tsx | 158 +++++++++++++++++ src/common/numberFunctions.ts | 63 +++++++ src/components/Apps/AppsDesktop.tsx | 11 +- src/components/Group/AddGroupList.tsx | 2 +- src/components/Group/Forum/NewThread.tsx | 2 - src/components/Group/Group.tsx | 15 +- .../Group/ListOfGroupPromotions.tsx | 2 +- src/components/Group/UserListOfInvites.tsx | 2 +- src/index.css | 3 +- 11 files changed, 367 insertions(+), 64 deletions(-) create mode 100644 src/common/BoundedNumericTextField.tsx create mode 100644 src/common/numberFunctions.ts diff --git a/src/App.tsx b/src/App.tsx index 94a4333..0f74145 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -45,6 +45,8 @@ import Info from "./assets/svgs/Info.svg"; import CloseIcon from "@mui/icons-material/Close"; import { JsonView, allExpanded, darkStyles } from 'react-json-view-lite'; import 'react-json-view-lite/dist/index.css'; +import HelpIcon from '@mui/icons-material/Help'; + import { createAccount, generateRandomSentence, @@ -112,6 +114,7 @@ import { useFetchResources } from "./common/useFetchResources"; import { Tutorials } from "./components/Tutorials/Tutorials"; import { useHandleTutorials } from "./components/Tutorials/useHandleTutorials"; import { CoreSyncStatus } from "./components/CoreSyncStatus"; +import BoundedNumericTextField from "./common/BoundedNumericTextField"; type extStates = | "not-authenticated" @@ -447,7 +450,16 @@ function App() { isFocusedRef.current = isFocused; }, [isFocused]); - + useEffect(()=> { + if(!shownTutorialsInitiated) return + if(extState === 'not-authenticated'){ + showTutorial('create-account') + } else if(extState === "create-wallet" && walletToBeDownloaded){ + showTutorial('important-information') + } else if(extState === "authenticated"){ + showTutorial('getting-started') + } + }, [extState, walletToBeDownloaded, shownTutorialsInitiated]) // const checkIfUserHasLocalNode = useCallback(async () => { // try { @@ -532,7 +544,7 @@ function App() { let wallet = structuredClone(rawWallet); const res = await decryptStoredWallet(password, wallet); - const wallet2 = new PhraseWallet(res, walletVersion); + const wallet2 = new PhraseWallet(res, wallet?.version || walletVersion); wallet = await wallet2.generateSaveWalletData( password, crypto.kdfThreads, @@ -588,43 +600,54 @@ function App() { setLtcBalanceLoading(false); }); }; - const sendCoinFunc = () => { - setSendPaymentError(""); - setSendPaymentSuccess(""); - if (!paymentTo) { - setSendPaymentError("Please enter a recipient"); - return; - } - if (!paymentAmount) { - setSendPaymentError("Please enter an amount greater than 0"); - return; - } - if (!paymentPassword) { - setSendPaymentError("Please enter your wallet password"); - return; - } - setIsLoading(true); - chrome?.runtime?.sendMessage( - { - action: "sendCoin", - payload: { - amount: Number(paymentAmount), - receiver: paymentTo.trim(), - password: paymentPassword, - }, - }, - (response) => { - if (response?.error) { - setSendPaymentError(response.error); - } else { - setIsOpenSendQort(false); - setIsOpenSendQortSuccess(true); - // setExtstate("transfer-success-regular"); - // setSendPaymentSuccess("Payment successfully sent"); - } - setIsLoading(false); + const sendCoinFunc = async () => { + try { + setSendPaymentError(""); + setSendPaymentSuccess(""); + if (!paymentTo) { + setSendPaymentError("Please enter a recipient"); + return; } - ); + if (!paymentAmount) { + setSendPaymentError("Please enter an amount greater than 0"); + return; + } + if (!paymentPassword) { + setSendPaymentError("Please enter your wallet password"); + return; + } + const fee = await getFee('PAYMENT') + + await show({ + message: `Would you like to transfer ${Number(paymentAmount)} QORT?` , + paymentFee: fee.fee + ' QORT' + }) + setIsLoading(true); + chrome?.runtime?.sendMessage( + { + action: "sendCoin", + payload: { + amount: Number(paymentAmount), + receiver: paymentTo.trim(), + password: paymentPassword, + }, + }, + (response) => { + if (response?.error) { + setSendPaymentError(response.error); + } else { + setIsOpenSendQort(false); + setIsOpenSendQortSuccess(true); + // setExtstate("transfer-success-regular"); + // setSendPaymentSuccess("Payment successfully sent"); + } + setIsLoading(false); + } + ); + } catch (error) { + //error + } + }; const clearAllStates = () => { @@ -1046,6 +1069,11 @@ function App() { try { if(hasSettingsChanged){ await showUnsavedChanges({message: 'Your settings have changed. If you logout you will lose your changes. Click on the save button in the header to keep your changed settings.'}) + } if(extState === 'authenticated') { + await showUnsavedChanges({ + message: + "Are you sure you would like to logout?", + }); } chrome?.runtime?.sendMessage({ action: "logout" }, (response) => { if (response) { @@ -1580,6 +1608,23 @@ function App() { alignItems: 'center' }} > + {(desktopViewMode === "apps" || desktopViewMode === "home") && ( + { + if(desktopViewMode === "apps"){ + showTutorial('qapps', true) + + } else { + showTutorial('create-account', true) + + } + }} > + + + )} + + { setExtstate("download-wallet"); @@ -1767,12 +1812,14 @@ function App() { Amount - setPaymentAmount(+e.target.value)} - autoComplete="off" + minValue={0} + maxValue={+balance} + allowDecimals={true} + initialValue={'0'} + allowNegatives={false} + afterChange={(e: string) => setPaymentAmount(+e)} /> @@ -2648,19 +2695,27 @@ function App() { aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description" > - {"Publish"} + {message.paymentFee ? "Payment" : "Publish"} {message.message} - - publish fee: {message.publishFee} - + {message?.paymentFee && ( + + payment fee: {message.paymentFee} + + )} + {message?.publishFee && ( + + publish fee: {message.publishFee} + + )}