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