Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat: The account form supports the `accountAgent` logic

haitaoo6350cb861e9f
diff --git a/ui/src/pages/Users/Settings/Account/index.tsx b/ui/src/pages/Users/Settings/Account/index.tsx
index aee15788..aaffade2 100644
--- a/ui/src/pages/Users/Settings/Account/index.tsx
+++ b/ui/src/pages/Users/Settings/Account/index.tsx
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { userCenterStore } from '@/stores';
-import { getUcSettings } from '@/services';
+import { getUcSettings, UcSettingAgent } from '@/services';
import { ModifyEmail, ModifyPassword, MyLogins } from './components';
@@ -11,17 +11,12 @@ const Index = () => {
keyPrefix: 'settings.account',
});
const { agent: ucAgent } = userCenterStore();
- const [accountAgent, setAccountAgent] = useState('');
+ const [accountAgent, setAccountAgent] = useState<UcSettingAgent>();
const initData = () => {
if (ucAgent?.enabled) {
getUcSettings().then((resp) => {
- if (
- resp.account_setting_agent?.enabled &&
- resp.account_setting_agent?.redirect_url
- ) {
- setAccountAgent(resp.account_setting_agent.redirect_url);
- }
+ setAccountAgent(resp.account_setting_agent);
});
}
};
@@ -31,10 +26,12 @@ const Index = () => {
return (
<>
<h3 className="mb-4">{t('heading')}</h3>
- {accountAgent ? (
- <a href={accountAgent}>{t('goto_modify', { keyPrefix: 'settings' })}</a>
+ {accountAgent?.enabled && accountAgent?.redirect_url ? (
+ <a href={accountAgent.redirect_url}>
+ {t('goto_modify', { keyPrefix: 'settings' })}
+ </a>
) : null}
- {!ucAgent?.enabled ? (
+ {!ucAgent?.enabled || accountAgent?.enabled === false ? (
<>
<ModifyEmail />
<ModifyPassword />