From b5ae09fe3b7c2295bee356fb0e111514f66d277d Mon Sep 17 00:00:00 2001 From: pandablue0809 Date: Tue, 19 Aug 2025 01:51:37 +0900 Subject: [PATCH 1/2] update some field and fix login pro --- components/EmailLoginPopup.js | 6 +- components/Home/PriceChart.js | 1 + pages/services/account-settings.js | 168 +++++++++++----------- styles/pages/account-settings.module.scss | 12 ++ styles/ui.scss | 1 + utils/index.js | 4 +- 6 files changed, 103 insertions(+), 89 deletions(-) diff --git a/components/EmailLoginPopup.js b/components/EmailLoginPopup.js index 6b2d25198..822edeb6f 100644 --- a/components/EmailLoginPopup.js +++ b/components/EmailLoginPopup.js @@ -57,7 +57,11 @@ export default function EmailLoginPopup({ isOpen, onClose, onSuccess, setAccount }) if (data?.data) { - setAccount({ ...data.data, pro: data.data.email }) + setAccount((prevAccount) => ({ + ...prevAccount, + ...data.data, + pro: data.data.email + })) } const partnerDataRaw = await axiosAdmin.get('partner').catch((error) => { diff --git a/components/Home/PriceChart.js b/components/Home/PriceChart.js index 7a58ef043..c52767456 100644 --- a/components/Home/PriceChart.js +++ b/components/Home/PriceChart.js @@ -429,6 +429,7 @@ export default function PriceChart({ currency, chartPeriod, setChartPeriod, hide ignore = true ctrl.abort() } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ currency, chartPeriod, diff --git a/pages/services/account-settings.js b/pages/services/account-settings.js index 83061b0f5..14cc442a5 100644 --- a/pages/services/account-settings.js +++ b/pages/services/account-settings.js @@ -9,7 +9,6 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import { getIsSsrMobile } from '../../utils/mobile' import CheckBox from '../../components/UI/CheckBox' import AddressInput from '../../components/UI/AddressInput' -import FormInput from '../../components/UI/FormInput' import { accountSettings } from '../../styles/pages/account-settings.module.scss' export const getServerSideProps = async (context) => { @@ -496,9 +495,9 @@ export default function AccountSettings({ return } if (/^[0-9a-fA-F]{32}$/.test(input)) { - valueHex = input.toUpperCase() + valueHex = input } else if (isEmailValid(input)) { - valueHex = md5(input).toUpperCase() + valueHex = md5(input) } else { setErrorMessage('Enter a valid email or a 32-character hex MD5 hash.') return @@ -733,7 +732,7 @@ export default function AccountSettings({ const tx = { TransactionType: 'AccountSet', Account: account.address, - WalletLocator: '' + WalletLocator: '0000000000000000000000000000000000000000000000000000000000000000' } setSignRequest({ request: tx, @@ -1022,58 +1021,7 @@ export default function AccountSettings({ {/* Basic ASF Flags */} {flagGroups.basic.map((flag) => renderFlagItem(flag, 'asf'))} - {/* NFTokenMinter Section */} - {!xahauNetwork && ( -
-
-
- Authorized NFToken Minter - {account?.address && ( - {currentNftTokenMinter ? currentNftTokenMinter : 'Not Set'} - )} -
- {currentNftTokenMinter ? ( - - ) : ( - - )} -
-
- Allows another account to mint NFTokens on behalf of this account. Requires setting the - asfAuthorizedNFTokenMinter flag and specifying the minter address. -
- {!currentNftTokenMinter && ( -
- - Enter the address that will be authorized to mint NFTokens for this account -
- )} - {currentNftTokenMinter && ( - To change the authorized minter, first clear the current one, then set a new one. - )} -
- )} + {/* Account Fields */}
@@ -1087,7 +1035,7 @@ export default function AccountSettings({ {currentDomain ? currentDomain : 'Not Set'} )} -
+
{currentDomain && (
- setDomainInput(e.target.value)} type="text" disabled={!account?.address} /> @@ -1129,7 +1077,7 @@ export default function AccountSettings({ {currentEmailHash ? currentEmailHash : 'Not Set'} )}
-
+
{currentEmailHash && (
- setEmailHashInput(e.target.value)} type="text" disabled={!account?.address} /> @@ -1169,7 +1117,7 @@ export default function AccountSettings({ MessageKey {account?.address && {currentMessageKey ? 'Set' : 'Not Set'}}
-
+
{currentMessageKey && (
- setMessageKeyInput(e.target.value)} type="text" disabled={!account?.address} /> @@ -1215,7 +1163,7 @@ export default function AccountSettings({ )}
-
+
{currentTransferRate && currentTransferRate > 0 && (
- setTransferRateInput(e.target.value)} type="text" inputMode="decimal" disabled={!account?.address} @@ -1258,7 +1206,7 @@ export default function AccountSettings({ {currentTickSize ? currentTickSize : 'Not Set'} )}
-
+
- setTickSizeInput(e.target.value)} type="text" inputMode="numeric" disabled={!account?.address} @@ -1291,7 +1239,7 @@ export default function AccountSettings({ {currentWalletLocator ? 'Set' : 'Not Set'} )}
-
+
{currentWalletLocator && (
- setWalletLocatorInput(e.target.value)} type="text" disabled={!account?.address} maxLength={64} @@ -1325,6 +1273,54 @@ export default function AccountSettings({ Optional hash locator for your wallet application.
+ + {/* NFTokenMinter Field */} + {!xahauNetwork && ( +
+
+
+ NFTokenMinter + {account?.address && ( + {currentNftTokenMinter ? currentNftTokenMinter : 'Not Set'} + )} +
+
+ {currentNftTokenMinter && ( + + )} + +
+
+
+ + Enter the address that will be authorized to mint NFTokens for this account +
+ {currentNftTokenMinter && ( + To change the authorized minter, first clear the current one, then set a new one. + )} +
+ )}
{/* Advanced options */} diff --git a/styles/pages/account-settings.module.scss b/styles/pages/account-settings.module.scss index 757bb7e86..3bf51ccc2 100644 --- a/styles/pages/account-settings.module.scss +++ b/styles/pages/account-settings.module.scss @@ -47,9 +47,21 @@ align-self: flex-end; width: auto; } + + .flag-info-buttons { + width: 100%; + display: flex; + justify-content: flex-end; + gap: 0.5rem; + } } } + .flag-info-buttons { + display: flex; + gap: 0.5rem; + } + .flag-info { display: flex; align-items: center; diff --git a/styles/ui.scss b/styles/ui.scss index f7ea29fd9..c197c2011 100644 --- a/styles/ui.scss +++ b/styles/ui.scss @@ -141,6 +141,7 @@ code { .code-highlight { background-color: var(--background-input-readonly); + word-break: break-all; } a, .link { diff --git a/utils/index.js b/utils/index.js index f8e1a4ef3..b2fb3aac7 100644 --- a/utils/index.js +++ b/utils/index.js @@ -310,14 +310,14 @@ export const useLocalStorage = (key, initialValue) => { const setValue = useCallback( (value) => { try { - const valueToStore = value instanceof Function ? value(storedValue) : value + const valueToStore = value instanceof Function ? value(state) : value setState(valueToStore) localStorage.setItem(key, JSON.stringify(valueToStore)) } catch { console.log('Error saving to localStorage') } }, - [key, setState] + [key, setState, state] ) const remove = useCallback(() => { From a98d920ca33680517d9d554ccd786f0467e2de0d Mon Sep 17 00:00:00 2001 From: Viacheslav Bakshaev Date: Fri, 22 Aug 2025 13:57:42 +0300 Subject: [PATCH 2/2] localStorage update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • No state in deps → stable function identity. • Always uses the latest state (prev) → no stale closure. • localStorage is updated with the exact value that was set. --- utils/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/utils/index.js b/utils/index.js index b2fb3aac7..b8999e852 100644 --- a/utils/index.js +++ b/utils/index.js @@ -310,14 +310,21 @@ export const useLocalStorage = (key, initialValue) => { const setValue = useCallback( (value) => { try { - const valueToStore = value instanceof Function ? value(state) : value - setState(valueToStore) - localStorage.setItem(key, JSON.stringify(valueToStore)) + if (typeof value === 'function') { + setState((prev) => { + const next = value(prev) + localStorage.setItem(key, JSON.stringify(next)) + return next + }) + } else { + setState(value) + localStorage.setItem(key, JSON.stringify(value)) + } } catch { console.log('Error saving to localStorage') } }, - [key, setState, state] + [key] ) const remove = useCallback(() => { @@ -936,4 +943,4 @@ export const xls14NftValue = (value) => { return false } -export const md5 = (text) => SparkMD5.hash(text) +export const md5 = (text) => SparkMD5.hash(text)