feat: The account form supports the `accountAgent` logic

This commit is contained in:
haitaoo 2023-04-18 11:53:13 +08:00
parent 7445dbc336
commit 6350cb861e
1 changed files with 8 additions and 11 deletions

View File

@ -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 />