mirror of https://gitee.com/answerdev/answer.git
feat: The account form supports the `accountAgent` logic
This commit is contained in:
parent
7445dbc336
commit
6350cb861e
|
@ -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 />
|
||||
|
|
Loading…
Reference in New Issue