mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
* refactor(auth): auth client api * fix: build * fix: dependencies * fix: fix T-2777 * fix: fix T-2776 * chore: update type * fix: build * fix: allowSignUp * fix: file name * fix: file name * refactor: client api * fix: build * chore: update name * fix: tsx must be loaded with --import instead of --loader * fix: type * fix: type * fix: type * fix: type * fix: bug * chore: improve wording * fix: test --------- Co-authored-by: chenos <chenlinxh@gmail.com>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import { observer, useForm } from '@formily/react';
|
|
import { useActionContext, usePlugin, useRecord, useRequest } from '@nocobase/client';
|
|
import { useEffect } from 'react';
|
|
import AuthPlugin from '..';
|
|
|
|
export const useValuesFromOptions = (options) => {
|
|
const record = useRecord();
|
|
const result = useRequest(
|
|
() =>
|
|
Promise.resolve({
|
|
data: {
|
|
...record.options,
|
|
},
|
|
}),
|
|
{
|
|
...options,
|
|
manual: true,
|
|
},
|
|
);
|
|
const { run } = result;
|
|
const ctx = useActionContext();
|
|
useEffect(() => {
|
|
if (ctx.visible) {
|
|
run();
|
|
}
|
|
}, [ctx.visible, run]);
|
|
return result;
|
|
};
|
|
|
|
export const useAdminSettingsForm = (authType: string) => {
|
|
const plugin = usePlugin(AuthPlugin);
|
|
const auth = plugin.authTypes.get(authType);
|
|
return auth?.components?.AdminSettingsForm;
|
|
};
|
|
|
|
export const Options = observer(() => {
|
|
const form = useForm();
|
|
const record = useRecord();
|
|
const Component = useAdminSettingsForm(form.values.authType || record.authType);
|
|
return Component ? <Component /> : null;
|
|
});
|