mirror of https://gitee.com/answerdev/answer.git
feat(admin/login): Complete login setting api interfacing
This commit is contained in:
parent
806e3c390d
commit
481d16ba16
|
@ -1096,7 +1096,7 @@ ui:
|
|||
label: Password
|
||||
btn_cancel: Cancel
|
||||
btn_submit: Submit
|
||||
user_modal:
|
||||
user_modal:
|
||||
title: Add new user
|
||||
form:
|
||||
fields:
|
||||
|
@ -1109,7 +1109,7 @@ ui:
|
|||
label: Password
|
||||
btn_cancel: Cancel
|
||||
btn_submit: Submit
|
||||
|
||||
|
||||
questions:
|
||||
page_title: Questions
|
||||
normal: Normal
|
||||
|
@ -1290,11 +1290,12 @@ ui:
|
|||
login:
|
||||
page_title: Login
|
||||
membership:
|
||||
label: Membership
|
||||
labelAlias: Allow new registrations
|
||||
title: Membership
|
||||
label: Allow new registrations
|
||||
text: Turn off to prevent anyone from creating a new account.
|
||||
private:
|
||||
label: Private
|
||||
title: Private
|
||||
label: Login required
|
||||
text: Only logged in users can access this community.
|
||||
|
||||
form:
|
||||
|
|
|
@ -363,6 +363,11 @@ export interface AdminSettingsCustom {
|
|||
custom_footer: string;
|
||||
}
|
||||
|
||||
export interface AdminSettingsLogin {
|
||||
allow_new_registrations: boolean;
|
||||
login_required: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description interface for Activity
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@ import { FC, useEffect, useState } from 'react';
|
|||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import type * as Type from '@/common/interface';
|
||||
import { getSeoSetting, putSeoSetting } from '@/services';
|
||||
import { getLoginSetting, putLoginSetting } from '@/services';
|
||||
import { SchemaForm, JSONSchema, initFormData, UISchema } from '@/components';
|
||||
import { useToast } from '@/hooks';
|
||||
import { handleFormError } from '@/utils';
|
||||
|
@ -15,25 +15,27 @@ const Index: FC = () => {
|
|||
const schema: JSONSchema = {
|
||||
title: t('page_title'),
|
||||
properties: {
|
||||
membership: {
|
||||
allow_new_registrations: {
|
||||
type: 'boolean',
|
||||
title: t('membership.label'),
|
||||
label: t('membership.labelAlias'),
|
||||
title: t('membership.title'),
|
||||
label: t('membership.label'),
|
||||
description: t('membership.text'),
|
||||
default: true,
|
||||
},
|
||||
private: {
|
||||
type: 'string',
|
||||
title: t('private.label'),
|
||||
login_required: {
|
||||
type: 'boolean',
|
||||
title: t('private.title'),
|
||||
label: t('private.label'),
|
||||
description: t('private.text'),
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
const uiSchema: UISchema = {
|
||||
membership: {
|
||||
allow_new_registrations: {
|
||||
'ui:widget': 'switch',
|
||||
},
|
||||
private: {
|
||||
login_required: {
|
||||
'ui:widget': 'switch',
|
||||
},
|
||||
};
|
||||
|
@ -43,11 +45,12 @@ const Index: FC = () => {
|
|||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
|
||||
const reqParams: Type.AdminSettingsSeo = {
|
||||
robots: formData.robots.value,
|
||||
const reqParams: Type.AdminSettingsLogin = {
|
||||
allow_new_registrations: formData.allow_new_registrations.value,
|
||||
login_required: formData.login_required.value,
|
||||
};
|
||||
|
||||
putSeoSetting(reqParams)
|
||||
putLoginSetting(reqParams)
|
||||
.then(() => {
|
||||
Toast.onShow({
|
||||
msg: t('update', { keyPrefix: 'toast' }),
|
||||
|
@ -63,11 +66,13 @@ const Index: FC = () => {
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
getSeoSetting().then((setting) => {
|
||||
getLoginSetting().then((setting) => {
|
||||
if (setting) {
|
||||
const formMeta = { ...formData };
|
||||
formMeta.robots.value = setting.robots;
|
||||
setFormData(formMeta);
|
||||
formMeta.allow_new_registrations.value =
|
||||
setting.allow_new_registrations;
|
||||
formMeta.login_required.value = setting.login_required;
|
||||
setFormData({ ...formMeta });
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
|
|
@ -129,3 +129,13 @@ export const getPageCustom = () => {
|
|||
export const putPageCustom = (params: Type.AdminSettingsCustom) => {
|
||||
return request.put('/answer/admin/api/siteinfo/custom-css-html', params);
|
||||
};
|
||||
|
||||
export const getLoginSetting = () => {
|
||||
return request.get<Type.AdminSettingsLogin>(
|
||||
'/answer/admin/api/siteinfo/login',
|
||||
);
|
||||
};
|
||||
|
||||
export const putLoginSetting = (params: Type.AdminSettingsLogin) => {
|
||||
return request.put('/answer/admin/api/siteinfo/login', params);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue